<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>图片列表</h1>
<div id="app">
    <div v-for="image in arr">
        <h3>{{image.title}}</h3>
        <a href="#" @click="del(image.id)">删除</a>
        <img width="200" :src="image.url" alt="">
    </div>
</div>
<!--引入vue-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<!--引入axios框架-->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    let vm = new Vue({
        el:"#app",
        data:{
            arr:[]
        },
        created:function () {
            axios.get("/select").then(function (response) {
                vm.arr = response.data;
            })
        },
        methods:{
            del:function (id) {
                if(confirm("您确认删除吗?")){
                    axios.get("/delete?id="+id).then(function () {
                        alert("删除完成!")
                        location.reload();
                    })
                }

            }
        }
    })
</script>
</body>
</html>